<template>
	<view class="pageBox">
		<view class="header" style="background-color: #FE5900;">
			<view class="top">
				<view class="left">
					<view class="headPortrait">
						<u-avatar :src="userInfo.headImage || '../../static/img/touxiang.jpg'" style="width: 100%;height: 100%;" img-mode="aspectFill" size="large"></u-avatar>
					</view>
					<view class="msg">
						<view class="msgTop">
							<view class="name">{{userName}}</view>
							<!-- <button type="default" size="mini" @click="daySign">{{ isSign ? '已签到' : '签到'}}</button> -->
						</view>
						<view class="msgBot">
							<view class="tel">邀请码:{{userInfo.inviteCode}}</view>
						</view>
					</view>
				</view>
				<view class="right">
					<!-- <view class="list">
						<view class="item" @click="toPage(0,'/pages/Mycollect/Mycollect')">
						<view class="item" @click="NotOpen">
							<view class="number">0</view>
							<view class="title">收藏夹</view>
						</view>
						<view class="item" @click="toShop">
						<view class="item" @click="NotOpen">
							<view class="number">0</view>
							<view class="title">关注店铺</view>
						</view>
						<view class="item" @click="NotOpen">
							<view class="number">0</view>
							<view class="title">足迹</view>
						</view>
						<view class="item" @click="toPage(0,'/pages/cardPackage/cardPackage')">
							<view class="number">3</view>
							<view class="title">红包卡券</view>
						</view>
					</view> -->
				</view>
			</view>
			
			<view class="item" @click="toPage(0,'/pages/my/myService/setting/index?uId='+userInfo.userId)">
				<view class="imgBox" style="width: 50upx;height: 50upx;"><image src="../../static/img/shezhi.png" mode=""></image></view>
			</view>
		</view>
	
		<view class="content">
			<!-- <view class="vipTask"> -->
				<!-- <view class="leftTitle" @click="toPage(0,'/pages/vipCenter/vipCenter')">
					<view class="icont" style="display: flex;align-items: center;justify-content: center;">
						<image src="../../static/img/kingtou.png" mode="" class="king"></image> -->
						<!-- <view class="iconfont icon-huangguan king"></view> -->
					<!-- </view>
					<view>会员中心</view>
				</view> -->
				<!-- <view class="rightTitle" @click="toPage(0,'/pages/taskList/taskList')">
					<view class="icont" style="display: flex;align-items: center;justify-content: center;">
						<image src="../../static/img/zhuanRenwu.png" mode="" style="width: 35upx;height: 35upx;"></image>
					</view>
					<view>转化任务</view>
				</view> -->
			<!-- </view> -->
			
			<view class="order">
					<view class="top">
						<view class="left">我的订单</view>
						<view class="right" @click="toPage(0,'/pages/order/order?state=0')">
							<text>查看全部订单</text>
							<view class="rightIcon iconfont icon-fanhui"></view>
						</view>
					</view>
					<view class="bottom">
						<view class="item" @click="toPage(0,'/pages/order/order?state=1')">
							<view class="imgBox">
								<image src="../../static/img/daifu.png" mode=""></image>
								<u-badge type="success" count="0" size="default" :offset="[-15,-30]" color="#FE5900" bgColor="#fff" :basecolor="true"></u-badge>
							</view>
							<view class="txt">待付款</view>
						</view>
						<!-- <view class="item" @click="toPage(0,'/pages/order/order?state=2')">
							<view class="imgBox" style="width: 60upx;height: 60upx;">
								<image src="../../static/img/daichuli.png" mode=""></image>
								<u-badge type="success" count="0" size="default" :offset="[-15,-25]" color="#FE5900" bgColor="#fff" :basecolor="true"></u-badge>
							</view>
							<view class="txt">待处理</view>
						</view> -->
						<view class="item" @click="toPage(0,'/pages/order/order?state=3')">
							<view class="imgBox">
								<image src="../../static/img/daifahuo.png" mode=""></image>
								<u-badge type="success" count="0" size="default" :offset="[-15,-20]" color="#FE5900" bgColor="#fff" :basecolor="true"></u-badge>
							</view>
							<view class="txt">待发货	</view>
						</view>
						<view class="item" @click="toPage(0,'/pages/order/order?state=4')">
							<view class="imgBox">
								<image src="../../static/img/daishouhuo.png" mode=""></image>
								<u-badge type="success" count="0" size="default" :offset="[-15,-25]" color="#FE5900" bgColor="#fff" :basecolor="true"></u-badge>
							</view>
							<view class="txt">待收货</view>
						</view>
						<!-- <view class="item" @click="toPage(0,'/pages/order/order?state=6')">
							<view class="imgBox">
								<image src="../../static/img/daipingjia.png" mode="" style="width: 56upx;"></image>
								<u-badge type="success" count="1" size="default" :offset="[-15,-25]" color="#FE5900" bgColor="#fff" :basecolor="true"></u-badge>
							</view>
							<view class="txt">待评价</view>
						</view> -->
						<view class="item" @click="toPage(0,'/pages/order/order?state=5')">
							<view class="imgBox">
								<image src="../../static/img/wancheng.png" mode=""></image>
								<u-badge type="success" count="0" size="default" :offset="[-15,-25]" color="#FE5900" bgColor="#fff" :basecolor="true"></u-badge>
							</view>
							<view class="txt">已完成</view>
						</view>
					</view>
			</view>
			<view class="order">
					<!-- <view class="top">
						<view class="left">划算买卖</view>
					</view> -->
					<view class="bottom">
						<!-- <view class="item" @click="toPage(0,'/pages/my/preSale/preSale')">
							<view class="imgBox" style="width: 50upx;height: 50upx;">
								<image src="../../static/img/myyushou.png" mode="">
									
								</image>
								<u-badge type="success" count="0" size="default" :offset="[-15,-20]" color="#FE5900" bgColor="#fff" :basecolor="true"></u-badge>
							</view>
							<view class="txt">我的预售</view>
						</view>
						<view class="item" @click="toPage(0,'/pages/my/sale/sale?type=0')">
							<view class="imgBox" style="width: 50upx;height: 50upx;">
								<image src="../../static/img/maichu.png" mode=""></image>
								<u-badge type="success" count="0" size="default" :offset="[-15,-30]" color="#FE5900" bgColor="#fff" :basecolor="true"></u-badge>
							</view>
							<view class="txt">我卖出的</view>
						</view> -->
						<view class="item" @click="toPage(0,'/pages/my/invate/invate')">
							<view class="imgBox" style="width: 50upx;height: 50upx;">
								<image src="../../static/img/invate.png" mode=""></image>
								<u-badge type="success" count="0" size="default" :offset="[-15,-30]" color="#FE5900" bgColor="#fff" :basecolor="true"></u-badge>
							</view>
							<view class="txt">分享</view>
						</view>
						<view class="item" @click="toPage(0,'/pages/vipCenter/vipCenter')">
							<view class="imgBox" style="width: 50upx;height: 50upx;">
								<image src="../../static/img/cash.png" mode=""></image>
								<u-badge type="success" count="0" size="default" :offset="[-15,-30]" color="#FE5900" bgColor="#fff" :basecolor="true"></u-badge>
							</view>
							<view class="txt">钱包</view>
						</view>
						<!-- <view class="item" @click="toPage(0,'/pages/notice/chat?name=客服娜娜')">
							<view class="imgBox" style="width: 50upx;height: 50upx;">
								<image src="../../static/img/icon_serveic.png" mode=""></image>
								<u-badge type="success" count="0" size="default" :offset="[-15,-30]" color="#FE5900" bgColor="#fff" :basecolor="true"></u-badge>
							</view>
							<view class="txt">客服</view>
						</view> -->
					</view>
			</view>
			<!-- <view class="order">
					<view class="morebottom">
						<view class="item" @click="toPage(0,'/pages/sharePage/sharePage?type=0')">
							<view class="imgBox" style="width: 56upx;height: 50upx;"><image src="../../static/img/shareGoods.png" mode=""></image></view>
							<view class="txt">分享商品</view>
						</view>
						<view class="item" @click="toPage(0,'/pages/sharePage/sharePage?type=1')">
							<view class="imgBox" style="width: 50upx;height: 50upx;"><image src="../../static/img/tuiguang.png" mode=""></image></view>
							<view class="txt">推广</view>
						</view>
						<view class="item" @click="toPage(0,'/pages/sharePage/sharePage?type=2')">
							<view class="imgBox" style="width: 56upx;height: 50upx;"><image src="../../static/img/fenxiangchengjiao.png" mode=""></image></view>
							<view class="txt">分享并成交</view>
						</view>
						<view class="item" @click="toPage(0,'/pages/sharePage/sharePage?type=3')">
							<view class="imgBox" style="width: 55upx;height: 50upx;"><image src="../../static/img/yushouxinshangpin.png" mode=""></image></view>
							<view class="txt">预售新商品</view>
						</view>
						<view class="item" @click="toPage(0,'/pages/notice/chat?name=客服娜娜')">
							<view class="imgBox" style="width: 50upx;height: 50upx;"><image src="../../static/img/icon_serveic.png" mode=""></image></view>
							<view class="txt">客服</view>
						</view>
						<view class="item" @click="toPage(0,'/pages/my/myService/setting/index')" v-for="(item,index) in moreList" :key="item+index">
							<view class="imgBox" style="width: 50upx;height: 50upx;"><image src="../../static/img/icon_serveic.png" mode=""></image></view>
							<view class="txt"></view>
						</view>
						<view class="item" v-if="moreList.length != 0">
							<view class="imgBox" style="width: 55upx;height: 45upx;"><image src="../../static/img/more.png" mode=""></image></view>
							<view class="txt">更多</view>
						</view>
					</view>
			</view> -->
			
			<button @click="exitLogin" type="default" style="margin-top: 30upx;background-color: #FF8B4C; color: #414141">退出登录</button>
			
			<!-- <view class="shoplist">
				<view class="top">
					<view class="left"></view>
					<view class="right">
						为你优选
					</view>
				</view>
				<goodsList :goodList="goodList"></goodsList>
			</view> -->
			
		</view>
		
	</view>
</template>

<script>
	import {quitLogin} from '../../api/login/index.js';
	import * as api  from '../../api/user/index.js';
	import goodsList from '@/components/goods-list/index';
	export default {
		componentName: 'goodsList',
		
		components: {
			goodsList
		},
		data() {
			return {
				userName:'',
				userInfo:{
					name:'请登录',
					inviteCode:'xxxxxxx',
					headImage:''
				},
				moreList:[],
				isSign:false,
				slides: [
					require('../../static/img/changePhoto.jpg'), 
					require('../../static/img/changePhoto.jpg'), 
					require('../../static/img/changePhoto.jpg')],
				indicatorDots: false,
				indicatorColor: '#000',
				indicatorActive: 'red',
				autoplay: true,
				interval: 4000,
				duration: 500,
				goodList: [{
						price: '￥120.00',
						title: '商品标题商品标题商品标题商品标题商品标题商品标题商品标题商品标题商品标题商品标题',
						Imgurl: '../../static/img/demo.png',
						id: 12
					},
					{
						price: '￥120.00',
						title: '商品标题商品标题商品标题商品标题商品标题商品标题商品标题商品标题商品标题商品标题',
						Imgurl: '../../static/img/demo.png',
						id: 13
					},
					{
						price: '￥120.00',
						title: '商品标题商品标题商品标题商品标题商品标题商品标题商品标题商品标题商品标题商品标题',
						Imgurl: '../../static/img/demo.png',
						id: 14
					},
					{
						price: '￥120.00',
						title: '商品标题商品标题商品标题商品标题商品标题商品标题商品标题商品标题商品标题商品标题',
						Imgurl: '../../static/img/demo.png',
						id: 15
					},
					{
						price: '￥120.00',
						title: '商品标题商品标题商品标题商品标题商品标题商品标题商品标题商品标题商品标题商品标题',
						Imgurl: '../../static/img/demo.png',
						id: 16
					}
				],
			}
		},
		onLoad() {
			
		},
		onPullDownRefresh() {
			  this.userName = uni.getStorageSync('userCode'),
			  this.getuserFun();
		       setTimeout(function () {
		           uni.stopPullDownRefresh();
		       }, 1000);
		   },
		onShow(){
			this.userName = uni.getStorageSync('userCode'),
			this.getuserFun();
		},
		methods: {
			NotOpen(){
				this.utils.toast('页面暂未开放哦');
			},
			async getuserFun() {
				try{
					const ret = await api.getUserInfo();
					this.userInfo = ret.data.obj
					this.globalData.userInfo =ret.data.obj ;
				}catch(error){
					uni.showToast({
						title:error.data.msg,
						icon:'none'
					})
				}
			},
			daySign() {
				// this.isSign = true;
				uni.navigateTo({
					url:'/pages/signIn/signIn'
				})
			},
			demo() {
				console.log(this.toPage())
				this.toPage(0, '/pages/index/index')
			},
			toShop(){
				uni.navigateTo({
					url:'/pages/focusOnStores/focusOnStores'
				})
			},
			toList(e) {
				if (e == 'user-info') {
					// this.toPage(0,'/pages/user-info/index');
				} else if (e == 'exit-login') {
					this.exitLogin();
				} else if (e == 'version-info') {
					this.toPage(0, '/pages/version-info/index');
				} else if (e == 'share') {
					uni.share({
						provider: "weixin",
						scene: "WXSceneSession",
						type: 0,
						href: 'https://a.app.qq.com/o/simple.jsp?pkgname=uni.UNI8F68529',
						title: "App",
						summary: "点击这里下载App",
						imageUrl: "https://yun.slxt.net:8058/UMobile/logo.png",
						success: (res) => {
							this.utils.toast('分享成功', 'success')
						},
						fail: function(err) {
							this.utils.toast('分享失败' + JSON.stringify(err))
						}
					});
				} else if (e == 'feedback') {
					this.toPage(0, '/pages/feedback/index');
				}
			},
			// 退出登录
			exitLogin() {
				uni.showModal({
					title: "",
					content: "是否退出登录",
					cancelText: "我再想想",
					confirmColor: "#3ECCA9",
					confirmText: "确认",
					success: async (e) => {
						if (e.confirm) {
							try{
								await quitLogin();
								uni.removeStorageSync('token')
								uni.removeStorageSync('userCode')
								this.toPage(1, '/pages/login/login');
							}catch(error){
								
							}
						}
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	@import "./index.scss";
	.on{
		background-color:#BEBEBE ;
		color: #616161;
	}
</style>
